<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    const HTTP_0_SUCCESS = 0;
    const HTTP_401_ERROR = 401;
    const HTTP_403_ERROR = 403;
    const HTTP_500_ERROR = 500;

    const CUSTOM_10000_LOGIN_ERROR = 10000;
    const CUSTOM_10001_PASSWORD_ERROR = 10001;
    const CUSTOM_10002_REPASSWORD_ERROR = 10002;
    const CUSTOM_10003_UPLOAD_ERROR = 10003;
    const CUSTOM_10004_FINGERPRINT_ERROR = 10004;

    const CUSTOM_10005_NOEDIT_ERROR = 10005;
    const CUSTOM_10006_NOEDIT_ERROR = 10006;

    public static function getMsg($code)
    {
        $msg = [
            self::HTTP_0_SUCCESS => '操作成功',
            self::HTTP_401_ERROR => '登录已失效，请重新登录',
            self::HTTP_403_ERROR => '没有权限，请登录后再试',
            self::HTTP_500_ERROR => '操作失败',

            self::CUSTOM_10000_LOGIN_ERROR => '用户名或密码错误',
            self::CUSTOM_10001_PASSWORD_ERROR => '旧密码错误',
            self::CUSTOM_10002_REPASSWORD_ERROR => '2次密码输入不一致',

            self::CUSTOM_10003_UPLOAD_ERROR => '上传文件失败',

            self::CUSTOM_10004_FINGERPRINT_ERROR => '您已提交过评价，请勿重复提交',
            self::CUSTOM_10005_NOEDIT_ERROR => '您的信息审核已通过，不能再修改信息',
            self::CUSTOM_10006_NOEDIT_ERROR => '班级下面有学生，不能删除',
        ];
        if (isset($msg[$code])) {
            return $msg[$code];
        } else {
            return $msg;
        }
    }
}
